package tech.aistar.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tech.aistar.mapper.CompanyMapper;
import tech.aistar.model.dto.CompanySearchDTO;
import tech.aistar.model.entity.Company;
import tech.aistar.service.ICompanyService;

import java.util.List;

@Service
public class CompanyServiceImpl implements ICompanyService {
    @Autowired
    private CompanyMapper companyMapper;


    @Override
    public List<Company> findAllCompany() {
        List<Company> list=null;
        list=companyMapper.getAll();
        return list;
    }

    @Override
    public Company getById(Integer id) {
      return   companyMapper.getById(id);
    }

    @Override
    public PageInfo<Company> findAllCompanyWithPage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Company> companyList = companyMapper.getAll();
        PageInfo<Company> pageInfo = new PageInfo<>(companyList);
        return pageInfo;
    }

    @Override
    public PageInfo<Company> findCompanyPageByCity(Integer pageNum, Integer pageSize,String city) {
        PageHelper.startPage(pageNum,pageSize);
        List<Company> list=companyMapper.getByCity(city);
        PageInfo<Company> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public List<Company> findCompanyByKind(String kind) {
        List<Company> list=null;
        list=companyMapper.getByKind(kind);
        return list;
    }

    @Override
    public List<Company> findCompanyByCollectMoneyState(Integer collectMoneyState) {
        List<Company> list=null;
        list=companyMapper.getByCollectMoneyState(collectMoneyState);
        return list;
    }

    @Override
    public List<Company> findCompanyByPeopleCounts(Integer peopleCountsState) {
        List<Company> list=null;
        list=companyMapper.getByPeopleCounts(peopleCountsState);
        return list;
    }

    @Override
    public PageInfo<Company> findCompanyByCityCollectMPeopleC(Integer pageNum, CompanySearchDTO companySearchDTO) {
        PageHelper.startPage(pageNum,12);
        List<Company> list=companyMapper.getComoanyByAll(companySearchDTO);
        PageInfo<Company> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
